#pragma once

#include "panel.h"
#include "bitmap.h"

class BMPColorPanel : public Panel
{
protected:
	int m_colorIndex;
	BitMaP ** m_bmp;
public:
	BMPColorPanel():m_bmp(0){}
	void set(BitMaP ** a_bmp, const int & a_colorIndex){m_bmp=a_bmp;m_colorIndex=a_colorIndex;}
	void draw(SDL_Surface * a_surface)
	{
		char buffer[30];
		SRect printArea(*getArea());
		if(m_bmp)
		{
			VSDL_FillRect(a_surface, &printArea, 
				RGBQUAD_toSurfaceColor(*((*m_bmp)->getColor(m_colorIndex)), a_surface->format));
		}
		sprintf_s(buffer, sizeof(buffer), "%d", m_colorIndex);
		VSDL_drawString(buffer, a_surface, getArea()->getMin());
	}
	int * getColorIndex()
	{return & m_colorIndex;}
	bool handleEvent(const SDL_Event & a_event){return false;}
};